<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>网页计算器</title>
</head>
<body>
<p>
    整数1：
    <input type="text" title="" id="zheng1">
</p>
<p>
    整数2：
    <input type="text" title="" id="zheng2">
</p>
<p>
    <button onclick="num('+')">相加</button>
    <button onclick="num('-')">相减</button>
    <button onclick="num('*')">相乘</button>
    <button onclick="num('/')">相除</button>
</p>
<p>
    结果：
    <input type="text" title="" id="jg">
</p>
<script>
    function num(e){
        var a = document.querySelector("#zheng1").value;
        var b = document.querySelector("#zheng2").value;
        a = Number(a);
        b = Number(b);
        switch (e){
            case "+":
                document.querySelector("#jg").value = a + b;
                break;
            case "-":
                document.querySelector("#jg").value = a - b;
                break;
            case "*":
                document.querySelector("#jg").value = a * b;
                break;
            case "/":
                document.querySelector("#jg").value = a / b;
                break;
        }
    }
</script>
</body>
</html>